package com.vsked.connection;

import java.sql.Connection;
import java.sql.DriverManager;

import com.vsked.bean.ConnectionInfo;

public class ConnectionUtil {
	public Connection getSqlServer2000Connection(ConnectionInfo ci) throws Exception{
		Class.forName(ci.getDriverStr());
		return DriverManager.getConnection("jdbc:microsoft:sqlserver://"+ci.getServerAddr()+":"+ci.getDbPort()+";databasename="+ci.getDbName(), ci.getUserName(), ci.getUserPass());
	}
	public Connection getOracleConnection(ConnectionInfo ci) throws Exception{
		Class.forName(ci.getDriverStr());
		return DriverManager.getConnection("jdbc:oracle:thin:@"+ci.getServerAddr()+":"+ci.getDbPort()+":"+ci.getDbName(), ci.getUserName(), ci.getUserPass());
	}
	public Connection getMySqlConnection(ConnectionInfo ci) throws Exception{
		Class.forName(ci.getDriverStr());
		return DriverManager.getConnection("jdbc:mysql://"+ci.getServerAddr()+":"+ci.getDbPort()+"/"+ci.getDbName()+"?user="+ci.getUserName()+"&password="+ci.getUserPass()+"&useUnicode=true&characterEncoding=8859_1");
	}
}
